package br.ufc.es.pds.mudproject.main;

import java.util.PriorityQueue;
import java.util.Queue;

import br.ufc.es.pds.mudproject.core.Comando;

public class Invoker extends Thread {
	
	boolean run;
	Queue<Comando> fila;
	
	public Invoker(){
		run = true;
		fila = new PriorityQueue<Comando>();	
	}
	
	public void adicionarComando( Comando comando) {
		fila.add(comando);
	}
	
	public void run(){
		
		while( run ) {
			if (! fila.isEmpty() ) {
				fila.poll().Executar();
			} 
			try {
				sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}	
	}
}
